package com.example.demoapplication;

import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-11-11
 * Time: 13:33
 */

@RestController
@RequestMapping("/user")
public class getLoginUser {
    @RequestMapping(value = "/getLoginUser" )
    public String getLoginUser(HttpSession session){
        String userName = (String)session.getAttribute("userName");//向下转型
        if(StringUtils.hasLength(userName)){
            return userName;
        }
        return "";
    }
}
